﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ArraysAndStrings.ArrayPairSum
{
    class MainProject
    {
        static void Main(string[] args)
        {
            int[] nums = new int[] { 6, 2, 6, 5, 1, 2 };
            Console.WriteLine(ArrayPairSum(nums));
            Console.ReadKey();
        }
        public static int ArrayPairSum(int[] nums)
        {
            Array.Sort(nums);
            int sum = 0;
            for (int i = 0; i < nums.Length; i+=2)
            {
                sum += Math.Min(nums[i], nums[i+1]);
            }
            return sum;
        }
    }
}
